from config import HOST


class ApiApproveTrust:
    # 初始化
    def __init__(self, session):
        # 获取session对象
        self.session = session
        # 认证url
        self.url_approve = HOST + "/member/approverealname"
        # 查询状态url
        self.url_approve_status = HOST + "/member/getapprove"
        # 开户url
        self.url_trust = HOST + "/trust/regsiter"

    # 1,认证接口封装
    def api_approve(self):
        # 请求数据
        data = {
            "realname": "张三",
            "card_id": "210213199012183012"
        }
        # 调用方法  难点：请求要multipart-from/data-> 必须data+files，json+files则不行 files可以随便传，作为占位符作用
        return self.session.post(url=self.url_approve, data=data, files={"x": "y"})

    # 2,查询认证状态封装
    def app_approve_status(self):
        return self.session.get(url=self.url_approve_status)

    # 3,开户接口
    def api_trust(self):
        return self.session.post(url=self.url_trust)
